Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Fix test_supervised_util_test for python3 #1152

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

reidhayes
Copy link

@reidhayes reidhayes commented Oct 31, 2020

Fixes this error in the unit-tests when running with python3:

======================================================================
ERROR: test_supervised_util_test_0 (fasttext.tests.test_script.TestFastTextUnitPy)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/build/work/003c13a04323e5dc26c2c02cd9c8df29e6c6/google3/runfiles/google3/third_party/py/fasttext/tests/test_script.py", line 590, in test
    "gen_" + test_name)(self, copy.deepcopy(kwargs))
  File "/build/work/003c13a04323e5dc26c2c02cd9c8df29e6c6/google3/runfiles/google3/third_party/py/fasttext/tests/test_script.py", line 229, in gen_test_supervised_util_test
    check(get_random_data(100, min_words_line=2))
  File "/build/work/003c13a04323e5dc26c2c02cd9c8df29e6c6/google3/runfiles/google3/third_party/py/fasttext/tests/test_script.py", line 210, in check
    for line in fid:
  File "<embedded stdlib>/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc7 in position 9: ordinal not in range(128)

Fixes errors like this testing in python3:

```
======================================================================
ERROR: test_supervised_util_test_0 (fasttext.tests.test_script.TestFastTextUnitPy)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/build/work/003c13a04323e5dc26c2c02cd9c8df29e6c6/google3/runfiles/google3/third_party/py/fasttext/tests/test_script.py", line 590, in test
    "gen_" + test_name)(self, copy.deepcopy(kwargs))
  File "/build/work/003c13a04323e5dc26c2c02cd9c8df29e6c6/google3/runfiles/google3/third_party/py/fasttext/tests/test_script.py", line 229, in gen_test_supervised_util_test
    check(get_random_data(100, min_words_line=2))
  File "/build/work/003c13a04323e5dc26c2c02cd9c8df29e6c6/google3/runfiles/google3/third_party/py/fasttext/tests/test_script.py", line 210, in check
    for line in fid:
  File "<embedded stdlib>/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc7 in position 9: ordinal not in range(128)
```
@facebook-github-bot
Copy link
Contributor

Hi @reidhayes!

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file.

In order for us to review and merge your code, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants